package com.dearbinge.opentapi.content.shopbanner;

import com.dearbinge.data.api.shopbanner.ShopBannerService;
import com.dearbinge.utils.ResultMsg;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@Api(description = "商城轮播图")
@RestController
@RequestMapping("/shopbanner")
@EnableAutoConfiguration
public class ShopBannerController {

    @Autowired
    private ShopBannerService shopBannerService;

    @ApiOperation(value = "获取首页类目", notes = "获取首页类目")
    @RequestMapping(value = "/getIndexBanner", method = RequestMethod.GET)
    public ResultMsg<List<Map>> getIndexBanner() {
        try {
            List<Map> list = shopBannerService.getIndexBanner();
            return ResultMsg.ok(list);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return ResultMsg.error(500, "系统异常");
    }
}
